<template>
      <el-row type="flex" class="header" justify="center">
        <el-col :span="18">
          <div class="h-row acea-row row-between-wrapper">
            <div class="h-left acea-row row-left">
              <div class="pictrue"><img src="@assets/images/news.png" alt="新闻简报"/></div>
              <div class="swiper">
                <el-carousel height="20px" direction="vertical"  indicator-position="none" loop>
                  <el-carousel-item v-for="(item, index) in roll" :key="index" style="background-color: rgb(51,51,51);">
                   <p>{{ item.info }}</p>
                  </el-carousel-item>
                </el-carousel>
              </div>
            </div>
            <div class="h-right acea-row row-right">
              <div class="h-right-bg acea-row">
                <el-dropdown class="acea-row" v-if=" userInfo.nickname">
                  <div class="user acea-row">
                    <div class="userName"> <el-link type="info" ><p>{{ userInfo.nickname}}</p></el-link></div>
                    <i class="el-icon-arrow-down el-icon--right" style="height:36px;line-height:36px"></i>
                  </div>
                  <el-dropdown-menu slot="dropdown">  
                    <el-dropdown-item >敬请期待</el-dropdown-item>
                    <!-- <el-dropdown-item divided  v-if="!isWeixin" @click="logout" >退出</el-dropdown-item> -->
                  </el-dropdown-menu>
                </el-dropdown>
                <el-link type="info" :underline="false" href="/login" v-else  v-cloak><p class="title">登录/注册</p></el-link>
                <el-link type="info" :underline="false" href="/order/list/0"><p class="title">我的订单</p></el-link>
                <el-link type="info" :underline="false" href="/user" ><p class="title">个人中心</p></el-link>
                <el-dropdown class="acea-row">
                  <span class="help d-line" style="font-size: 14px; color: #909399;">
                    客户服务<i class="el-icon-arrow-down el-icon--right"></i>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item  >敬请期待</el-dropdown-item>
                    <el-dropdown-item divided>......</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
</template>
<script>
import { getUser } from "@api/user";
import {getHomeData} from "@api/public";
import {  getLogout } from "@api/user";
import { clearAuthStatus } from "@libs/wechat";
import {  isWeixin } from "@utils";

export default {
    name:"HomeNavigation",
    data:function(){
        return {
            roll:[],
            userInfo: {},
            isWeixin: false,
        }
    },
    mounted: function() {
      let that = this;
      this.User();
      this.isWeixin = isWeixin();
      getHomeData().then(res => {
        that.$set(that, "roll", res.data.roll);
       });
    },
    methods: {
      User: function() {
      let that = this;
      getUser().then(res => {
        that.userInfo = res.data;
      });
    },
    logout: function() {
      this.$dialog.confirm({
        mes: "确认退出登录?",
        opts: () => {
          getLogout()
            .then(res => {
              this.$store.commit("LOGOUT");
              clearAuthStatus();
              location.href = location.origin;
              console.log(res);
            })
            .catch(err => {
              console.log(err);
            });
        }
      });
    }
    }
    
};
</script>
<style scoped>
    .header {
      height:36px;
      background-color: rgb(51,51,51);
    }
    .header .h-row {
      width: 1090px;
      height: 36px;
      margin: 0 auto;
    }
    .header .h-row .h-left {
      width: 400px;
      height: 36px;
    }
    .header .h-row .h-left .swiper {
      width: 300px;
      height: 20px;
      margin-top: 9px;
      margin-left: 10px;
    }
    .header .h-row .h-left .swiper p{
      font-size: 12px;
      height: 20px;
      line-height: 20px;
      color:#b4a078;
    }
    .header .h-row .h-left .pictrue {
      width: 88px;
      height: 18px;
      margin-top: 9px;
      border-right: 1px solid #ccc;
      padding-right: 10px;
    }
    .header .h-row .h-left .pictrue img {
      width: 100%;
      height: 100%;
    }
    .header .h-row .h-right{
      width: 560px; 
      height: 36px;
    }
    .header .h-row .h-right .h-right-bg {
      font-size: 12px;
      color: #ccc;
    }
    .header .h-row .h-right .h-right-bg .d-line{
      font-size: 14px;
      color: #909399;
      font-family: 'PingFang SC', 'STHeitiSC-Light', 'Helvetica-Light', arial, sans-serif, 'Droid Sans Fallback';
      line-height: 16px;
    }
    .header .h-row .h-right .h-right-bg .title {
      padding: 0 10px;
      border-left: 1px solid #ccc;
      height: 16px;
      line-height: 16px;
      margin: 0 auto;
    }
    .header .h-row .h-right .h-right-bg .help {
      height: 36px;
      line-height: 36px;
      border-left: 1px solid #ccc;
      padding: 0 10px;
      font-size: 12px;
      color: #ccc;
      cursor: pointer;
    }
    .header .h-row .h-right .h-right-bg .user {
      width: 90px;
      height: 36px;
    }
    .header .h-row .h-right .h-right-bg .user .userName {
      width: 70px;
      height: 36px;
    }
    .header .h-row .h-right .h-right-bg .user .userName p {
      font-size: 12px;
      text-align: center;
      line-height: 36px;
      overflow: hidden;
      text-overflow:ellipsis;
      white-space: nowrap;
    }
</style>